def place(t):
    global x
    global a
    OK=True
    for j in range(t):
        if x[j] and a[t][j]==0:
            OK=False
            break
    return OK

def  backtrack(t):
    global cn,bestn,n,bestx,x
    if (t > n):
        bestx = x[:]
        bestn=cn
        return
    if place(t-1):
        x[t-1]=1
        cn += 1
        backtrack(t+1)
        cn -= 1
    if (cn+n-t>bestn):
        x[t-1]=0
        backtrack(t+1)
if __name__ =="__main__":
    # a = [[0,1,1,0,0],[1,0,1,1,1],[1,1,0,1,1],[0,1,1,0,1],[0,1,1,1,0]]
    arr = input("")
    arr1=[int(n) for n in arr.split(',')]
    arr = input("")
    arr2=[int(n) for n in arr.split(',')]
    arr = input("")
    arr3=[int(n) for n in arr.split(',')]
    arr = input("")
    arr4=[int(n) for n in arr.split(',')]


    b=[0,1,1,0,0]
    c=[0,1,1,1]
    if(arr1==c):
        a=[arr1,arr2,arr3,arr4]
    elif(arr1==b):
        arr = input("")
        arr5 = [int(n) for n in arr.split(',')]
        a=[arr1,arr2,arr3,arr4,arr5]
    else:
        arr = input("")
        arr5 = [int(n) for n in arr.split(',')]
        arr = input("")
        arr6 = [int(n) for n in arr.split(',')]
        a=[arr1,arr2,arr3,arr4,arr5,arr6]
    # print(a)
    n = len(a)
    x=[i for i in range(n)]
    bestx =None
    bestn = cn = 0
    backtrack(1)
    print("最大团顶点个数：", bestn)
    print("最大团为：", bestx)